#include"integernode.h"
#include<sstream>

IntegerNode::IntegerNode() : val(0), undef(true) {}
IntegerNode::IntegerNode(IntegerNode const & i) : val(i.val), undef(i.undef) {}
IntegerNode::IntegerNode(int i, bool u) : val(i), undef(u) {}
IntegerNode::~IntegerNode() {}

ProgramNode * IntegerNode::defun() const {
	return 0;
}

string IntegerNode::toString() const {
	if (undef)
		return "undefined";
	else {
		stringstream s;
		s << val;
		return s.str();
	}
}
	
ExpressionNode * IntegerNode::copy() const {
	return new IntegerNode(*this);
}

bool IntegerNode::isFreeVar(VariableNode const & v) const {
	return false;
}

bool IntegerNode::isBoundVar(VariableNode const & v) const {
	return false;
}

ExpressionNode * IntegerNode::eval(ProgramNode const & state) const {
	return copy();
}

ExpressionNode * IntegerNode::subst(VariableNode const & v, ExpressionNode const * e) {
	return copy();
}

IntegerNode IntegerNode::deint() const {
	return *this;
}
